﻿@{
    ViewData["Title"] = "Edit";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<div id="divForm" style="margin:2px;padding:2px;">

    <el-form ref="form" :model="form" label-width="80px">
        <el-row :gutter="24">
            <el-col :span="6">
                <el-form-item label="项目编码" required>
                    <el-input v-model="form.code"></el-input>
                </el-form-item>
            </el-col>
        </el-row>
        <el-row :gutter="24">
            <el-col :span="6">
                <el-form-item label="项目名称" required>
                    <el-input v-model="form.projectName"></el-input>
                </el-form-item>
            </el-col>
        </el-row>
        <el-row :gutter="24">
            <el-col :span="6">
                <el-form-item label="配置方式">
                    <el-radio-group v-model="form.storageType">
                        <el-radio :label='1'>共享目录</el-radio>
                        <el-radio :label='2'>Mysql</el-radio>
                    </el-radio-group>
                </el-form-item>
            </el-col>
        </el-row>
        <el-row :gutter="24">
            <el-col :span="6">
                <el-form-item label="项目排序">
                    <el-input v-model="form.orderIndex" type="number"></el-input>
                </el-form-item>
            </el-col>
        </el-row>
        <el-row :gutter="24">
            <el-col :span="6">
                <el-form-item label="状态">
                    <el-radio-group v-model="form.enabled">
                        <el-radio :label='true'>启用</el-radio>
                        <el-radio :label='false'>禁用</el-radio>
                    </el-radio-group>
                </el-form-item>
            </el-col>
        </el-row>
        <el-row :gutter="24">
            <el-col :span="24">
                <el-form-item label="备注">
                    <el-input type="textarea" v-model="form.remark"></el-input>
                </el-form-item>
            </el-col>
        </el-row>
        <el-form-item>
            <el-button type="primary" @@click="SaveProject()" v-show="pageButtons.includes('saveproject')">保存</el-button>
            <el-button @@click="Back()">返回</el-button>
        </el-form-item>
    </el-form>
</div>
<script>
    Vue.prototype.$axios = axios

    var vueProject = new Vue({
        el: '#divForm',
        data() {
            return {
                pageButtons: [],
                form: {
                    id: getQueryString("id") || 0,
                    code: "",
                    projectName: "",
                    orderIndex: 0,
                    remark: "",
                    storageType: 2,
                    enabled: true
                }
            }
        },
        created() {
            var _this = this;
            _this.GetProject();

            _this.$getMenuButtons();
        },
        methods: {
            GetProject() {
                var _this = this;
                _this.$get("@Url.Action("getproject", "project")?id=" + _this.form.id).then((res) => {
                    _this.form = res;
                });
            },
            SaveProject() {
                var _this = this;
                _this.form.orderIndex = parseInt(_this.form.orderIndex);
                _this.$post("@Url.Action("saveproject", "project")", _this.form).then((res) => {
                    _this.form.id = res.data.id;
                    _this.$success(res.message, function () {
                        _this.$back(true);
                    });
                });
            },
            Back() {
                  this.$back();
            }
        }
    });
</script>
